<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: JYC
  Date: 2022/4/8
  Time: 17:51:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>记账管理系统</title>
    <script src="js/*"></script>
    <link rel="stylesheet" type="text/css" href="themes/*">
    <script>
        function clr() {
            $("#se").val("1");
            $("#ad1").val(null);
            $("#ad2").val(null);
            $("#aa1").val(null);
            $("#aa2").val(null);
        }

        function toAdd() {
            $("#add_f").css('display', 'block');
        }

        function hide() {
            $("#add_f").css('display', 'none');
        }

        window.onload = function () {
            <%--alert(${sessionScope.type});--%>
            <%--+" "+${sessionScope.d1}+'、'+${sessionScope.d2}+'、'+${sessionScope.a1}+'、'${sessionScope.a2});--%>
        }
    </script>
</head>
<body>
<div class="easyui-layout">
    <div data-options="region:'north',title:'North Title',split:true" style="height:100px;"><h3 align="center">记账管理系统</h3></div>
    <div data-options="region:'center',title:'center title'" style="padding:5px;background:#eee;">
    <form action="main" method="post">
        类型：<select name="a_type" id="se">
        <c:forEach items="${sessionScope.types}" var="t">
            <option value="${t.id}"
                    <c:if test="${sessionScope.type!=null && t.id==sessionScope.type}">selected="selected"</c:if>
                <%--<c:if test="${t.id==1}">selected="selected"</c:if>--%>>${t.name}</option>
        </c:forEach>
    </select>&emsp;
        记账时间：<input type="date" name="a_date1" id="ad1" value="${sessionScope.d1}">
        -<input type="date" name="a_date2" id="ad2" value="${sessionScope.d2}">&emsp;
        记账金额：<input type="text" name="a_amo1" id="aa1" value="${sessionScope.a1}">
        -<input type="text" name="a_amo2" id="aa2" value="${sessionScope.a2}">&emsp;
        <input type="submit" value="搜索">&emsp;&emsp;<button type="button" onclick="clr()">清空</button>
    </form>
    <hr>
    <button onclick="toAdd()">新增记账</button>
    <div id="add_f" style="display: none">
        <form method="post" action="add">
            类型：<select name="typeId">
            <c:forEach items="${sessionScope.types}" var="t">
                <c:if test="${t.id!=1}">
                    <option value="${t.id}">${t.name}</option>
                </c:if>
            </c:forEach>
        </select>&emsp;
            标题：<input type="text" name="title">&emsp;
            金额：<input type="text" name="price">&emsp;
            备注：<input type="text" name="explain">&emsp;
            <input type="submit" value="添加">&emsp;
            <button type="button" onclick="hide()">取消</button>
        </form>
    </div>
    <table border="1px">
        <tr>
            <th>编号</th>
            <th>标题</th>
            <th>时间</th>
            <th>类型</th>
            <th>金额</th>
            <th>说明</th>
        </tr>
        <c:forEach items="${sessionScope.billList}" var="bill">
            <tr>
                <td>${bill.id}</td>
                <td>${bill.title}</td>
                    <%--<fmt:formatDate value="${item.taskTime}" pattern="yyyy-MM-dd HH:mm:ss"/>--%>
                <td><fmt:formatDate value="${bill.time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td><c:forEach items="${sessionScope.types}" var="ttt">
                    <c:if test="${ttt.id==bill.typeId}">${ttt.name}</c:if>
                </c:forEach></td>
                <td><c:if test="${bill.typeId=='2'}">+</c:if>
                    <c:if test="${bill.typeId=='3'}">-</c:if>
                        ${bill.price}</td>
                <td>${bill.explain}</td>
            </tr>
        </c:forEach>
    </table>
    <a href="main?sx=-1">上一页</a>
    &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
    <a href="main?sx=1">下一页</a>
    </div>
</div>
</body>
</html>
